﻿using HCQ2_IBLL;
using HCQ2_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_BLL
{
    public partial class T_VRAddressBLL: IT_VRAddressBLL
    {
        /// <summary>
        ///  编辑收货地址
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
       public int ModifyAddr(T_VRAddress dto)
        {
            if (dto.is_default)
            {
                //当前地址设置为默认时，查看之前的记录有无默认地址，有则取消
                var query = Select(s => s.user_id == dto.user_id && s.id != dto.id);
                if (query.Count > 0)
                    Modify(new T_VRAddress { is_default = false }, s => s.user_id == dto.user_id, "is_default");
            }
            return Modify(dto, s => s.id == dto.id, "user_id", "user_name", "phone", "area", "addr", "addr_mark", "is_default", "update_id", "update_name", "update_date", "gps_x", "gps_y", "areaID");
        }
    }
}